/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.agreement.entity.supplychainserviceagreement;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.modules.base.entity.customer.Customer;
import com.jeesite.modules.base.entity.guarantor.Guarantor;
import com.jeesite.modules.sys.entity.Company;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 供应链服务协议Entity
 * @author Kilo
 * @version 2021-03-03
 */
@Table(name="t_supply_chain_service_agreement", alias="a", columns={
		@Column(name="supply_chain_service_agreement_id", attrName="supplyChainServiceAgreementId", label="供应链服务协议ID", isPK=true),
		@Column(name="supply_chain_service_agreement_code", attrName="supplyChainServiceAgreementCode", label="协议编号"),
		@Column(name="sign_date", attrName="signDate", label="签订日期"),
		@Column(name="sign_location", attrName="signLocation", label="签订地点"),
		@Column(includeEntity=DataEntity.class),
		@Column(name="start_date", attrName="startDate", label="开始日期"),
		@Column(name="end_date", attrName="endDate", label="结束日期"),
		@Column(name="company_id", attrName="company.companyCode", label="甲方", comment="甲方(受托方)"),
		@Column(name="company_address", attrName="companyAddress", label="公司地址"),
		@Column(name="company_contact_person", attrName="companyContactPerson", label="联系人"),
		@Column(name="company_phone", attrName="companyPhone", label="电话"),
		@Column(name="company_email", attrName="companyEmail", label="邮箱"),
		@Column(name="company_contact_person_addr", attrName="companyContactPersonAddr", label="联系人通讯地址"),
		@Column(name="customer_id", attrName="customer.customerId", label="乙方", comment="乙方(委托方)"),
		@Column(name="customer_address", attrName="customerAddress", label="公司地址"),
		@Column(name="customer_contact_person", attrName="customerContactPerson", label="联系人"),
		@Column(name="customer_phone", attrName="customerPhone", label="电话"),
		@Column(name="customer_email", attrName="customerEmail", label="邮箱"),
		@Column(name="customer_contact_person_addr", attrName="customerContactPersonAddr", label="联系人通讯地址"),
		@Column(name="guarantor_id", attrName="guarantorId", label="丙方", comment="丙方(担保方)"),
		@Column(name="guarantor_address", attrName="guarantorAddress", label="现住"),
		@Column(name="guarantor_phone", attrName="guarantorPhone", label="电话"),
		@Column(name="guarantor_id_number", attrName="guarantorIdNumber", label="身份证号码"),
		@Column(name="guarantor_email", attrName="guarantorEmail", label="邮箱"),
		@Column(name="status1", attrName="status1", label="状态"),
	}, joinTable={
			@JoinTable(type=Type.LEFT_JOIN, entity= Company.class, attrName="company", alias="u11",
					on="u11.company_code = a.company_id", columns={
					@Column(name="company_code", label="公司编码", isPK=true),
					@Column(name="company_name", label="公司名称", isQuery=false),
			}),
			@JoinTable(type=Type.LEFT_JOIN, entity= Customer.class, attrName="customer", alias="u12",
					on="u12.customer_id = a.customer_id", columns={
					@Column(name="customer_id", label="客户编码", isPK=true),
					@Column(name="customer_name", label="客户名称", isQuery=false),
			}),
		@JoinTable(type=Type.LEFT_JOIN, entity= Guarantor.class, attrName="guarantor", alias="u13",
				on="u13.guarantor_id = a.guarantor_id", columns={
				@Column(name="guarantor_id", label="担保方编码", isPK=true),
				@Column(name="guarantor_name", label="担保方名称", isQuery=false),
		}),
	}, orderBy="a.update_date DESC"
)
public class SupplyChainServiceAgreement extends DataEntity<SupplyChainServiceAgreement> {
	
	private static final long serialVersionUID = 1L;
	private String supplyChainServiceAgreementId;		// 供应链服务协议ID
	private String supplyChainServiceAgreementCode;		// 协议编号
	private Date signDate;		// 签订日期
	private String signLocation;		// 签订地点
	private Date startDate;		// 开始日期
	private Date endDate;		// 结束日期
	private String companyAddress;		// 公司地址
	private String companyContactPerson;		// 联系人
	private String companyPhone;		// 电话
	private String companyEmail;		// 邮箱
	private String companyContactPersonAddr;		// 联系人通讯地址
	private String customerAddress;		// 公司地址
	private String customerContactPerson;		// 联系人
	private String customerPhone;		// 电话
	private String customerEmail;		// 邮箱
	private String customerContactPersonAddr;		// 联系人通讯地址
	private String guarantorId;		// 丙方(担保方)
	private String guarantorAddress;		// 现住
	private String guarantorPhone;		// 电话
	private String guarantorIdNumber;		// 身份证号码
	private String guarantorEmail;		// 邮箱
	private Company company;
	private Customer customer;
	private Guarantor guarantor;
	private String status1;

	public Guarantor getGuarantor() {
		return guarantor;
	}

	public void setGuarantor(Guarantor guarantor) {
		this.guarantor = guarantor;
	}

	public String getStatus1() {
		return status1;
	}

	public void setStatus1(String status1) {
		this.status1 = status1;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public SupplyChainServiceAgreement() {
		this(null);
	}

	public SupplyChainServiceAgreement(String id){
		super(id);
	}
	
	public String getSupplyChainServiceAgreementId() {
		return supplyChainServiceAgreementId;
	}

	public void setSupplyChainServiceAgreementId(String supplyChainServiceAgreementId) {
		this.supplyChainServiceAgreementId = supplyChainServiceAgreementId;
	}
	
	@Length(min=0, max=100, message="协议编号长度不能超过 100 个字符")
	public String getSupplyChainServiceAgreementCode() {
		return supplyChainServiceAgreementCode;
	}

	public void setSupplyChainServiceAgreementCode(String supplyChainServiceAgreementCode) {
		this.supplyChainServiceAgreementCode = supplyChainServiceAgreementCode;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	@NotNull(message="签订日期不能为空")
	public Date getSignDate() {
		return signDate;
	}

	public void setSignDate(Date signDate) {
		this.signDate = signDate;
	}
	
	@NotBlank(message="签订地点不能为空")
	@Length(min=0, max=50, message="签订地点长度不能超过 50 个字符")
	public String getSignLocation() {
		return signLocation;
	}

	public void setSignLocation(String signLocation) {
		this.signLocation = signLocation;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	@NotNull(message="开始日期不能为空")
	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	@NotNull(message="结束日期不能为空")
	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
	
	@NotBlank(message="公司地址不能为空")
	@Length(min=0, max=255, message="公司地址长度不能超过 255 个字符")
	public String getCompanyAddress() {
		return companyAddress;
	}

	public void setCompanyAddress(String companyAddress) {
		this.companyAddress = companyAddress;
	}
	
	@NotBlank(message="联系人不能为空")
	@Length(min=0, max=100, message="联系人长度不能超过 100 个字符")
	public String getCompanyContactPerson() {
		return companyContactPerson;
	}

	public void setCompanyContactPerson(String companyContactPerson) {
		this.companyContactPerson = companyContactPerson;
	}
	
	@NotBlank(message="电话不能为空")
	@Length(min=0, max=100, message="电话长度不能超过 100 个字符")
	public String getCompanyPhone() {
		return companyPhone;
	}

	public void setCompanyPhone(String companyPhone) {
		this.companyPhone = companyPhone;
	}
	
	@NotBlank(message="邮箱不能为空")
	@Length(min=0, max=100, message="邮箱长度不能超过 100 个字符")
	public String getCompanyEmail() {
		return companyEmail;
	}

	public void setCompanyEmail(String companyEmail) {
		this.companyEmail = companyEmail;
	}
	
	@NotBlank(message="联系人通讯地址不能为空")
	@Length(min=0, max=255, message="联系人通讯地址长度不能超过 255 个字符")
	public String getCompanyContactPersonAddr() {
		return companyContactPersonAddr;
	}

	public void setCompanyContactPersonAddr(String companyContactPersonAddr) {
		this.companyContactPersonAddr = companyContactPersonAddr;
	}
	
	@NotBlank(message="公司地址不能为空")
	@Length(min=0, max=255, message="公司地址长度不能超过 255 个字符")
	public String getCustomerAddress() {
		return customerAddress;
	}

	public void setCustomerAddress(String customerAddress) {
		this.customerAddress = customerAddress;
	}
	
	@NotBlank(message="联系人不能为空")
	@Length(min=0, max=100, message="联系人长度不能超过 100 个字符")
	public String getCustomerContactPerson() {
		return customerContactPerson;
	}

	public void setCustomerContactPerson(String customerContactPerson) {
		this.customerContactPerson = customerContactPerson;
	}
	
	@NotBlank(message="电话不能为空")
	@Length(min=0, max=100, message="电话长度不能超过 100 个字符")
	public String getCustomerPhone() {
		return customerPhone;
	}

	public void setCustomerPhone(String customerPhone) {
		this.customerPhone = customerPhone;
	}
	
	@NotBlank(message="邮箱不能为空")
	@Length(min=0, max=100, message="邮箱长度不能超过 100 个字符")
	public String getCustomerEmail() {
		return customerEmail;
	}

	public void setCustomerEmail(String customerEmail) {
		this.customerEmail = customerEmail;
	}
	
	@NotBlank(message="联系人通讯地址不能为空")
	@Length(min=0, max=255, message="联系人通讯地址长度不能超过 255 个字符")
	public String getCustomerContactPersonAddr() {
		return customerContactPersonAddr;
	}

	public void setCustomerContactPersonAddr(String customerContactPersonAddr) {
		this.customerContactPersonAddr = customerContactPersonAddr;
	}
	
	@NotBlank(message="丙方不能为空")
	@Length(min=0, max=64, message="丙方长度不能超过 64 个字符")
	public String getGuarantorId() {
		return guarantorId;
	}

	public void setGuarantorId(String guarantorId) {
		this.guarantorId = guarantorId;
	}
	
	@NotBlank(message="现住不能为空")
	@Length(min=0, max=200, message="现住长度不能超过 200 个字符")
	public String getGuarantorAddress() {
		return guarantorAddress;
	}

	public void setGuarantorAddress(String guarantorAddress) {
		this.guarantorAddress = guarantorAddress;
	}
	
	@NotBlank(message="电话不能为空")
	@Length(min=0, max=100, message="电话长度不能超过 100 个字符")
	public String getGuarantorPhone() {
		return guarantorPhone;
	}

	public void setGuarantorPhone(String guarantorPhone) {
		this.guarantorPhone = guarantorPhone;
	}
	
	@NotBlank(message="身份证号码不能为空")
	@Length(min=0, max=100, message="身份证号码长度不能超过 100 个字符")
	public String getGuarantorIdNumber() {
		return guarantorIdNumber;
	}

	public void setGuarantorIdNumber(String guarantorIdNumber) {
		this.guarantorIdNumber = guarantorIdNumber;
	}
	
	@NotBlank(message="邮箱不能为空")
	@Length(min=0, max=100, message="邮箱长度不能超过 100 个字符")
	public String getGuarantorEmail() {
		return guarantorEmail;
	}

	public void setGuarantorEmail(String guarantorEmail) {
		this.guarantorEmail = guarantorEmail;
	}
	
	public Date getSignDate_gte() {
		return sqlMap.getWhere().getValue("sign_date", QueryType.GTE);
	}

	public void setSignDate_gte(Date signDate) {
		sqlMap.getWhere().and("sign_date", QueryType.GTE, signDate);
	}
	
	public Date getSignDate_lte() {
		return sqlMap.getWhere().getValue("sign_date", QueryType.LTE);
	}

	public void setSignDate_lte(Date signDate) {
		sqlMap.getWhere().and("sign_date", QueryType.LTE, signDate);
	}
	
	public Date getCreateDate_gte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
	}

	public void setCreateDate_gte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
	}
	
	public Date getCreateDate_lte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
	}

	public void setCreateDate_lte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
	}

	public Date getStartDate_gte() {
		return sqlMap.getWhere().getValue("start_date", QueryType.GTE);
	}

	public void setStartDate_gte(Date startDate) {
		sqlMap.getWhere().and("start_date", QueryType.GTE, startDate);
	}

	public Date getStartDate_lte() {
		return sqlMap.getWhere().getValue("start_date", QueryType.LTE);
	}

	public void setStartDate_lte(Date startDate) {
		sqlMap.getWhere().and("start_date", QueryType.LTE, startDate);
	}

	public Date getEndDate_gte() {
		return sqlMap.getWhere().getValue("end_date", QueryType.GTE);
	}

	public void setEndDate_gte(Date endDate) {
		sqlMap.getWhere().and("end_date", QueryType.GTE, endDate);
	}

	public Date getEndDate_lte() {
		return sqlMap.getWhere().getValue("end_date", QueryType.LTE);
	}

	public void setEndDate_lte(Date endDate) {
		sqlMap.getWhere().and("end_date", QueryType.LTE, endDate);
	}

	public void setStartDate_check(Date startDate){
		sqlMap.getWhere().andBracket("start_date", QueryType.LTE, startDate).and("end_date", QueryType.GTE,startDate );
	}
	public Date getStartDate_check(){
		return sqlMap.getWhere().getValue("start_date", QueryType.LTE);
	}
	public void setEndDate_check(Date endDate){
		sqlMap.getWhere().orBracket("start_date", QueryType.LTE, endDate).and("end_date", QueryType.GTE,endDate ).endBracket().endBracket();
	}
	public Date getEndDate_check(){
		return sqlMap.getWhere().getValue("end_date", QueryType.GTE);
	}
}